using UnityEngine;
using Yoozoo.Managers;

namespace Gameplay.PVE.TurnBase
{
    public class CombineElement : ElementBase
    {
        private int combineType;
        public override void Execute()
        {
            base.Execute();
            combineType = GetValue("CombineType");
            if (combineType == 1) //击飞
            {
                var arg = ClassManager.Get<HitFloatArg>();
                float lastTime = GetValue("LastTime") / 1000f;
                float velocityY = lastTime / 2 * GravityComponent.gravity;
                arg.velocity = new Vector3(0,velocityY,0);
                arg.source = source;
                target.Transmit(ETransmitType.HitFloat,arg);
            }
            else if (combineType == 2) //湿身
            {
                var arg = ClassManager.Get<ChangeColorArg>();
                arg.rgb = new Vector4(0,0,1,1);
                arg.amount = 0.7f;
                target.Transmit(ETransmitType.AddColor,arg);
            }
            else if (combineType == 3) //冷气
            {
                var arg = ClassManager.Get<ChangeColorArg>();
                arg.rgb = new Vector4(1,1,1,1);
                arg.amount = 0.7f;
                target.Transmit(ETransmitType.AddColor,arg);
            }
            else if (combineType == 4)
            {
                
            }
            if (config.flyText != null)
            {
                //PveFlyTextManager.Instance.ShowFlyText(config.flyText,target.Data.position,1,0.5f,ETextColor.Blue);
            }
        }

        public override void Free()
        {
            base.Free();
            if (combineType == 2) //湿身
            {
                var arg = ClassManager.Get<ChangeColorArg>();
                arg.rgb = new Vector4(0,0,1,1);
                arg.amount = 0.7f;
                target.Transmit(ETransmitType.RemoveColor,arg);
            }
            else if (combineType == 3) //冷气
            {
                var arg = ClassManager.Get<ChangeColorArg>();
                arg.rgb = new Vector4(1,1,1,1);
                arg.amount = 0.7f;
                target.Transmit(ETransmitType.RemoveColor,arg);
            }
        }
    }
}